package com.lcq.study.javabase;

/**
 * @ClassName ExceptionTest
 * @Description TODO
 * @Author lichuanqi
 * @Date 2021/4/19 16:51
 * @Version 1.0
 **/
public class ExceptionTest {
    public static void main(String[] args) {
        try {
            //throwException();
            throwMyException();
        } catch (MyException e) {
            System.out.println("MyException:" + e.getMessage());
        } catch (Exception e) {
            System.out.println("Exception:" + e.getMessage());
        }
    }

    public static void throwMyException() {
        throw new MyException("出错了");
    }

    public static void throwException() {
        int i = 2 / 0;
    }
}

class MyException extends RuntimeException {
    public MyException(String msg) {
        super(msg);
    }
}
